package com.plate.bpm.web.persistence;


import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.plate.bpm.web.model.ConsoleBean;


/**
 *作者： 李志刚
 *时间：2015-8-25
 */
public interface ConsoleMapper {

	@Select("select * from manager_flow where activity_id = #{activitiId} and process_definition_key = #{processKey}")
	public ConsoleBean getManagerFlow(@Param("activitiId") String activitiId,@Param("processKey") String processKey);
	
	@Select("select name from role where id=#{id}")
	public String getOrgNameByRoleId(@Param("id") String id);
	
	@Insert("insert into manager_flow(process_definition_id, process_definition_key," +
			" activity_id, assignee, candidate_users, candidate_groups) " +
			" values(#{bean.process_definition_id}, #{bean.process_definition_key}, " +
			" #{bean.activity_id}, #{bean.assignee}," +
			" #{bean.candidate_users}, #{bean.candidate_groups})")
	public void save(@Param("bean") ConsoleBean bean);
	
	
	@Update("update manager_flow set candidate_groups=#{bean.candidate_groups}" +
			" where process_definition_key= #{bean.process_definition_key} and activity_id = #{bean.activity_id}")
	public void update(@Param("bean")ConsoleBean bean);
	
	
	@Select("select candidate_groups from manager_flow where" +
						" process_definition_key = #{prcDefinitionKey}" +
						" and activity_id = #{activityId}")
	public String getGroupId(@Param("prcDefinitionKey") String prcDefinitionKey, 
							@Param("activityId") String activityId);
}

	